<?php
# database_driver.php
# Adept Integrity, CMSC 345
#
# This file provides functions are used and reused to pull information from
# the database, is wrapped sql queries.

include(config.php);

# Returns class sections that match the search parameters.
# Object returned is an array of assosciative rays with the mapping of
# 
function search_courses($search_parameters){

	$year = addslashes($search_parameters['year']);
	$department = addslashes($search_parameters['department']);
	$semester = addslashes($search_parameters['semester']);
	$instructor = addslashes($search_parameters['instructor']);
	$name = addslashes($search_parameters['name']);
	$number = addslashes($search_parameters['number']);
	$section = addslashes($search_parameters['section']);
	
	$query = "select for course, section where course.id = section.id"
	
	if ($year != null){
		$query .= " and course.year = " . $year;
	}
	
	if ($department != null){
		$query .= " and course.department = '" . $department . "'";
	}
	
	if ($semester != null){
		$query .= "and course.semester = '" . $semester . "'";
	}

	if ($instructor != null){
		$query .= "and section.instructor = '" . $instructor . "'";
	}
	
	if ($name != null){
		$query .= "and course.name = '" . $name . "'";
	}
	
	if ($number != null){
		$query .= "and course,number = '" . $number . "'";
	}

	if ($number != null){
		$query .= "and course,number = '" . $section . "'";
	}

	return mysql_query($query);
}


?>



